package com.longge;

public class PivotIndex {

    public int pivotIndex(int[] nums) {

        int leftSum = 0;
        int rightSum = 0;
        for (int num : nums) {
            rightSum += num;
        }
        for (int i = 0; i < nums.length; i++) {
            if (leftSum == rightSum - nums[i]) {
                return i;
            }
            leftSum += nums[i];
            rightSum -= nums[i];
        }
        return -1;

    }

    public static void main(String[] args) {
        int[] que = {-1,-1,-1,1,1,1};
        int i = new PivotIndex().pivotIndex(que);

    }

}
